<template>
  <div class="home">
   <el-form :model="form" label-width="50px">
     <el-form-item label="邮箱">
       <el-input v-model="form.email"></el-input>
     </el-form-item>
     <el-form-item label="密码">
       <el-input v-model="form.password"></el-input>
     </el-form-item>
   </el-form>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">立即创建</el-button>
    </el-form-item>
  </div>
</template>

<script>
// @ is an alias to /src
import HelloWorld from '@/components/HelloWorld.vue'
import {ref,reactive,toRefs} from "vue"
import axios from "axios"
export default {
  setup(){
    const data=reactive(
        {
          form:{
          email:"",
          password:""
        }
        }
    )
    const onSubmit = () => {
      axios.post('http://47.93.208.86:49165/users', data.form)
          .then(function (response) {
            console.log(response);
          })
          .catch(function (error) {
            console.log(error);
          });
    }
  // const onSubmit=function(){
  //
  //   console.log(data.form)
  //   }
    return {
      ...toRefs(data),
      onSubmit
    }
  },
  name: 'Home',
  components: {
    HelloWorld
  }
}
</script>
